package com.qumitech.visualnovel.service.redpacket.impl;

import com.alibaba.fastjson.JSONObject;
import com.qumitech.visualnovel.component.util.HttpInvokeUtil;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.UrlConstant;
import com.qumitech.visualnovel.service.exception.ExceptionService;
import com.qumitech.visualnovel.service.redpacket.RedPacketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author ywxie
 * @date 2019/12/4 17:06
 * @description
 */
@Service
public class RedPacketServiceImpl implements RedPacketService {

    private final String RedPacketConsoleUrl = "/redpacket/console";

    @Autowired
    private ExceptionService exceptionService;

    @Override
    public Map<String, Object> listRedPacketAdminByConditions(Map<String, String> paramMap) {
        String url = UrlConstant.SERVER_URL + RedPacketConsoleUrl;
        String body = HttpInvokeUtil.httpGet(url, paramMap, null);
        BaseRsp rsp = JSONObject.parseObject(body, BaseRsp.class);
        exceptionService.getFailureResultEnum(rsp);
        Map<String, Object> rspMap = (Map<String, Object>) rsp.getData();
        return rspMap;
    }
}
